<html>
	<head>
		<title>新增课程</title>
		<link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
		<script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
	</head>
	<body>
		<div class="layui-col-xs6 layui-col-xs-offset1" style="margin-top: 20px;">
			<form class="layui-form">
			  <div class="layui-form-item">
				  <label class="layui-form-label">课程名称</label>
				  <div class="layui-input-block">
				  	<input type="text" id="name" placeholder="请输入课程名称" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-form-item layui-form-text">
				  <label class="layui-form-label">课程描述</label>
				  <div class="layui-input-block">
				  	<textarea id="description" placeholder="请输入内容" class="layui-textarea"></textarea>
				  </div>
			  </div>
			  <div class="layui-form-item">
				  <div class="layui-input-block">
				    <button onclick="addCourse()" type="button" class="layui-btn">新建课程</button>
				    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
				  </div>
			  </div>
			</form>
		</div>
	</body>
	<script type="text/javascript">
		layui.use('form', function(){
			var form = layui.form;
		})
		function addCourse(){
			layui.use('layer', function(){
				var layer = layui.layer;
				var index = layer.load(1);
				var name = $("#name").val();
				var description = $("#description").val();
				$.post('course/add', {
					name: name,
					description: description
				}, function(res){
					layer.close(index)
					layer.alert(res.message+',<br>班级号：'+res.data)
				}, "json")
			})
		}
	</script>
</html>